<template>
	<view class="content">
		<view class="head-top">
			<view class="btn" @tap="gotoHome">

			</view>
			<video :src="playVideoSrc" controls class="video-box"></video>
			<scroll-view scroll-x="true" class="gundong-box" :show-scrollbar="false">
				<view v-for="(i,index) in videoList" :key="index" :class="current==index?'active':''"
					@tap="playThis(i, index)" class="btn-box">
					{{index+1}}
				</view>
			</scroll-view>
		</view>
		<view class="item-box">
			<view class="item-box-top"></view>
			<view class="item-box-mid">
				<text class="item-box-mid-title">{{title}}</text>
				<u-parse :content="fuwenben"></u-parse>
			</view>
			<view class="item-box-bottom"></view>
		</view>

		<view class="weibu">

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				pcType: 1,
				itemCurrent: 0,
				videoType: '',
				playVideoSrc: '',
				videoList: [],
				fuwenben: '',
				title: '',
			};
		},
		onLoad(e) {
			this.videoType = e.type
			this.getVideoList()
		},
		methods: {
			getVideoList() {
				uni.request({
					url: this.$api + '/potato-studio/video/video/list',
					method: "GET",
					data: {
						pcType: this.pcType,
						videoType: this.videoType,
						pageSize: 1000,
						pageNo: 1
					}
				}).then((res) => {
					if (res[1].data.result.records.length <= 0) {
						uni.showToast({
							mask: true,
							title: '暂无视频列表',
							icon: 'none'
						})
					} else {
						this.videoList = res[1].data.result.records
						//默认播放第一个
						this.playVideoSrc = this.videoList[0].videoUrl
						this.title = this.videoList[0].title
						this.fuwenben = this.videoList[0].introduce
						console.log('this.videoList', this.videoList)
					}

				})

			},
			playThis(i, index) {
				console.log(index)
				this.current = index
				this.title = i.title
				this.playVideoSrc = i.videoUrl
				this.fuwenben = i.introduce
			},
			gotoHome() {
				uni.navigateBack({
					delta: 0
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: url('https://qingchenghai-1.oss-cn-hangzhou.aliyuncs.com/static/video-list/xunhuan-bg.png') repeat-y center top;
		background-size: 100% auto;
	}

	.head-top {
		width: 750rpx;
		height: 864rpx;
		background: url('https://qingchenghai-1.oss-cn-hangzhou.aliyuncs.com/static/video-list/head-top.jpg') no-repeat center center;
		background-size: 100% 100%;
		display: flex;
		flex-direction: column;
		position: relative;
	}

	.btn {
		width: 218rpx;
		height: 102rpx;
		background: url('https://qingchenghai-1.oss-cn-hangzhou.aliyuncs.com/static/video-list/gohome-btn.png') no-repeat center center;
		background-size: 100% 100%;
		margin-top: 8rpx;
		margin-left: 36rpx;
	}

	.video-box {
		width: 688rpx;
		height: 388rpx;
		margin: 0 auto;
		margin-top: 88rpx;
	}

	.item-box {
		display: flex;
		flex-direction: column;
		margin: 0 auto;
		margin-top: -70rpx;
		position: relative;
	}

	.item-box-top {
		width: 736rpx;
		height: 58rpx;
		background: url('https://qingchenghai-1.oss-cn-hangzhou.aliyuncs.com/static/video-alone/spjs-box-top.png') no-repeat center center;
		background-size: 100% 100%;
	}

	.item-box-mid {
		width: 636rpx;
		// height: auto;
		background: url('https://qingchenghai-1.oss-cn-hangzhou.aliyuncs.com/static/video-alone/spjs-box-mid.png') repeat-y center center;
		background-size: 100% auto;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 0 50rpx;
	}

	.item-box-bottom {
		width: 736rpx;
		height: 84rpx;
		background: url('https://qingchenghai-1.oss-cn-hangzhou.aliyuncs.com/static/video-alone/spjs-box-bottom.png') no-repeat center center;
		background-size: 100% 100%;
	}

	.weibu {

		width: 750rpx;
		height: 218rpx;
		background: url('https://qingchenghai-1.oss-cn-hangzhou.aliyuncs.com/static/video-list/weibu1.png') no-repeat center center;
		background-size: 100% 100%;
	}

	.gundong-box {
		width: 100%;
		height: 60rpx;
		margin-top: 66rpx;
		white-space: nowrap;
	}

	.btn-box {
		width: 92rpx;
		height: 52rpx;
		border: 2px solid #fff;
		border-radius: 16rpx;
		background: rgba(207, 187, 17, 0.6);
		margin: 0 6rpx;
		color: #F3F3F3;
		text-align: center;
		line-height: 52rpx;
		font-size: 12px;
		display: inline-block;
	}

	.btn-box.active {
		background: rgba(255, 255, 255, 0.6);
		color: #232323;
	}

	.item-box-mid-title {
		text-align: center;
		font-size: 14px !important;
		margin-bottom: 20rpx;
	}
</style>
